<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>平台用户管理</title>
<%@include file="/WEB-INF/base.jspf"%>
 
<style>
	.modal-dialog {
		max-width: 1000px;
	}

.layui-inline {
	height: 100px;
}

#hymc {
	margin: 2px;
	height: 37px;
}
.btn-control-startOrBan {
	transition: background-color 0.3s;
}
.modal-body > p{
	display:flex;
	align-items:center;
	margin-right:16px;
	margin-bottom:16px;
}
.modal-body {
	display:flex;
	flex-wrap:wrap;
}
.modal-body > p > span {
	width:130px;
}
.modal-body > p > .form-control {
	width:250px;
}
table th,table tr,table td {
text-align: center;
vertical-align:middle;
}
#notice-text, .yue-addNewAccount-input {
	visibility: hidden;
}
#notice-text.active, .yue-addNewAccount-input.active {
	visibility: visible;
}
</style>
	</head>
	<body>
			<div>
				<div class="" style="padding:16px 0;display:flex;align-items:center;justify-content:space-between;">
					<div style="display:flex;align-items:center;">
						<input type="text" id="guanjianzi" class="form-control" placeholder="用户名" style="width:200px;margin-right:16px;"> 
						<input type="text" id="signinIp" class="form-control" placeholder="登录ip" style="width:200px;margin-right:16px;"> 
						<input type="text" id="bankCardNumber" class="form-control" placeholder="银行卡号" style="width:200px;margin-right:16px;"> 
						<input type="text" id="bankAccountName" class="form-control" placeholder="银行账户名" style="width:200px;margin-right:16px;"> 
						<button class="layui-btn layui-btn-radius" id="id-searchTableBtn">查询</button>
						<button class="layui-btn layui-btn-radius" id="id-resetTableBtn">重置</button>
						<button class="layui-btn layui-btn-radius" id="id-searchTableBtn-zhuanyi">转移下级</button>
					</div>
					<button class="layui-btn layui-btn-radius" id="id-addNewUserBtn">新增</button>
				</div>
			<div>
				<table id="table-i-userList" class="class-tableDataTable table table-striped table-bordered table-hover">
					 <thead>
						<tr>
						<th style="display:none;"></th>
						<th style="">用户账号</th>
						<th>账户余额</th>
						<th>注册时间</th>
						<th>登录时间</th>
						<th>手机号码</th>
						<th>注册IP</th>
						<th>登录IP</th>
						<th>用户等级</th>
						<th>用户状态</th>
						<th>用户操作</th>
						</tr>
					</thead>
					<tbody>
					</tbody> 
				</table>
			</div>

		</div>
<div class="modal fade" id="noticeModal" tabindex="-1" role="dialog" aria-labelledby="noticeModal" aria-hidden="true" style="z-index:1051;">
    <div class="modal-dialog class-fake-alert">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body" ></div>
            <div class="modal-footer">	      
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>  

<!-- 模态框（Modal） -->
<div class="modal fade" id="editAndBianJiModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:1000px!important;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
            	<p><span>ID编号:</span><input class="form-control" id="input-i-id" readonly /></p>
            	<p><span>用户余额：</span><input class="form-control input-c-canEdit" id="input-i-balance" readonly /></p>
            	<p><span>创建时间：</span><input class="form-control" id="input-i-createtime" readonly /></p>
            	<p><span>上级代理：</span><input class="form-control" id="input-i-dailimingchen" readonly /></p>
            	<p><span>邀请链接：</span><input class="form-control" id="input-i-icode" readonly /></p>
            	<p><span>登录IP：</span><input class="form-control" id="input-i-lastIp" readonly /></p>
            	<p><span>登录时间：</span><input class="form-control" id="input-i-lastTime" readonly /></p>
            	<p><span>代理金额：</span><input class="form-control input-c-canEdit" id="input-i-money" readonly /></p>
            	<p><span>用户账号：</span><input class="form-control" id="input-i-name" readonly /></p>
            	<p><span>用户昵称：</span><input class="form-control" id="input-i-nicheng" readonly /></p>
            	<p><span>未登录时间：</span><input class="form-control" id="input-i-notTime" readonly /></p>
            	<p><span>用户密码：</span><input class="form-control" id="input-i-pass" readonly /></p>
            	<p><span>QQ账号：</span><input class="form-control" id="input-i-qq" readonly /></p>
            	<p><span>注册IP：</span><input class="form-control" id="input-i-registerIp" readonly /></p>
            </div>
            <div class="modal-footer" style="text-align: center;">
                <button type="button" class="btn btn-default btn-lg" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->


<!-- 模态框（Modal） -->
<div class="modal fade" id="addNewAccountModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:1000px!important;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <form>
	            <div class="modal-body">
	            	<p id="notice-text" style="color:red;font-weight:bold;width:100%;">用户名已经存在</p>
	            	<p><span>用户账号：</span><input data-add="name" class="form-control" id="add-i-name" required="required" /></p>
	            	<p><span>用户密码：</span><input data-add="pass" class="form-control" id="add-i-pass" required="required"  /></p>
	            	<p><span>确认密码：</span><input class="form-control" id="add-i-passRepeat" required="required"  /></p>
	            	<p><span>QQ账号：</span><input data-add="qq"  class="form-control" id="add-i-qq" required="required" /></p>
	            	<p><span>手机号：</span><input data-add="telephone" class="form-control" id="add-i-phone" required="required" /></p>
	            	<p><span>账户类型：</span>
	            		<select id="select-i-accountType" data-add="state" class="form-control">
	            			<option value="1">普通账号</option>
	            			<option value="3">内部账号</option>
	            		</select>
	            	</p>
	            	<p class="yue-addNewAccount-input active"><span>用户余额：</span><input data-add="balance" class="form-control" type="number" id="add-i-balance" value="0" /></p>
	            </div>
            </form>
            <div class="modal-footer" style="text-align: center;">
                <button type="button" class="btn btn-primary" id="btn-i-addNewAccountBtn">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- 模态框（Modal） -->
<div class="modal fade" id="editPassWord" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
              <p style="display:flex;align-items:center;white-space:nowrap;">请输入新的密码：<input id="input-i-newPassWordValue" placeholder="6-16位(可包含字母或数字)" type="password" class="form-control" /></p>
             </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn-i-saveNewPassWord">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<!-- 模态框（Modal） -->
<div class="modal fade" id="editBankCard" tabindex="-1" role="dialog" aria-labelledby="editBankCard" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
            <input hidden="hidden" class="input-bank-auto" name="id" />
            <input hidden="hidden" class="input-bank-auto" name="userid">
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">开户姓名：</span><input required id="input-i-kaihuxingming" type="text" name="xingming" class="input-bank-auto form-control" /></p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">开户银行：</span>
	              <select class="form-control input-bank-auto" required id="bankName-input-i" name="kaihuhang">
						<option value="中国工商银行">中国工商银行</option>
						<option value="中国建设银行">中国建设银行</option>
						<option value="中国银行">中国银行</option>
						<option value="中国农业银行">中国农业银行</option>
						<option value="交通银行">交通银行</option>
						<option value="招商银行">招商银行</option>
						<option value="中信银行">中信银行</option>
						<option value="中国民生银行">中国民生银行</option>
						<option value="兴业银行">兴业银行</option>
						<option value="上海浦东发展银行">上海浦东发展银行</option>
						<option value="中国邮政储蓄银行">中国邮政储蓄银行</option>
						<option value="中国光大银行">中国光大银行</option>
						<option value="平安银行">平安银行</option>
						<option value="华夏银行">华夏银行</option>
						<option value="北京银行">北京银行</option>
						<option value="广发银行">广发银行</option>
						<option value="上海银行">上海银行</option>
						<option value="江苏银行">江苏银行</option>
						<option value="恒丰银行">恒丰银行</option>
						<option value="浙商银行">浙商银行</option>
						<option value="南京银行">南京银行</option>
						<option value="宁波银行">宁波银行</option>
						<option value="渤海银行">渤海银行</option>
						<option value="杭州银行">杭州银行</option>
						<option value="东亚银行">东亚银行</option>
						<option value="深圳发展银行">深圳发展银行</option>
						<option value="厦门银行">厦门银行</option>
						<option value="广州农商银行">广州农商银行</option>
						<option value="广东农信">广东农信</option>
						<option value="广西农村信用社">广西农村信用社</option>
						<option value="福建农村信用社">福建农村信用社</option>
						<option value="贵州农村信用社">贵州农村信用社</option>
						<option value="桂林银行">桂林银行</option>
						<option value="东莞农村商业银行">东莞农村商业银行</option>
						<option value="深圳农商银行">深圳农商银行</option>
						<option value="佛山顺德农村商业银行">佛山顺德农村</option>
						<option value="贵阳银行">贵阳银行</option>
						<option value="柳州银行">柳州银行</option>
						<option value="浙江农村信用社">浙江农村信用社</option>
						<option value="东莞银行">东莞银行</option>						
					</select>
              </p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">开户支行：</span><input required name="zhihang"  type="text" class="form-control input-bank-auto" /></p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">开户行地址：</span><input required name="kaihudizhi"  type="text" class="form-control input-bank-auto" /></p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">银行卡账号：</span><input required name="bankNum"  type="text" class="form-control input-bank-auto" /></p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">提款密码：</span><input required name="zhifupass"  type="password" class="form-control input-bank-auto" /></p>
              <p style="display:flex;align-items:center;white-space:nowrap;"><span style="width:80px;margin-right:16px;">确认密码：</span><input required name="repeatfupass" type="password" class="form-control input-bank-auto" /></p>
             </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="btn-i-saveNewBankBtn">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->


<!-- 模态框（Modal）转移下级的模态框 -->
<div class="modal fade" id="addNewAccountModal-zhuanyi" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:1000px!important;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <form>
	            <div class="modal-body">
	            	<p  style="color:red;font-weight:bold;width:100%;">注意：用户的赔率请使用百分比修改，格式如下：1%：最低0.1%，最高则是代理的最高赔率</p>
	            	<p><span>上级用户名：</span><input class="form-control" id="add-i-name-Superior" required="required" /></p>
	            	<p><span>被转移的用户名：</span><input class="form-control" id="add-i-subordinate" required="required"  /></p>
	            	<p><span>转移以后的赔率：</span><input class="form-control" id="add-i-odds" required="required"  /></p>
	            </div>
            </form>
            <div class="modal-footer" style="text-align: center;">
                <button type="button" class="btn btn-primary" id="btn-i-addNewAccountBtn-zhuanyi">确认</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->

<script type="text/javascript" src="/js/zhengzeTools.js"></script>
	<script>
	
	$("#select-i-accountType").on("change", function(e) {
		if ($(e.currentTarget).val() === "3") {
			$(".yue-addNewAccount-input").addClass("active")
		} else {
			$(".yue-addNewAccount-input").removeClass("active")
		}
	})
	var IS_USER_EXITS = false
	$("#id-addNewUserBtn").on("click", function(e) {
		$("#addNewAccountModal").modal("show")
	})
	$("#add-i-name").on("blur", function(e) {
		var newRequest = {
				url: "/kajhsgweasdqtwehghasfdnsak6868/findUserInfo.do",	
				type: "post",
				data: {name: $("#add-i-name").val()},
				success: function(data) {
					var newData = JSON.parse(data)
					if (newData.data != null) {
						$("#notice-text").addClass("active")
						IS_USER_EXITS = true
					} else {
						$("#notice-text").removeClass("active")
						IS_USER_EXITS = false
					}
				},
				error: function(status) {
					showNoticeModal("网络繁忙！")
				}
			}
			ajax(newRequest)		
	})
	var obj = {
		btnName: "#btn-i-addNewAccountBtn",
		divName: "#addNewAccountModal",
		isRegArray: [
		             {inputValue: function() {
		            	 return $("#add-i-name").val()
		            	 //用户名正则，4到16位（字母，数字，下划线，减号）
		             }, regValue:/^[a-zA-Z0-9_-]{4,16}$/, noticeText:"账号必须是4到17位(字母，数字，下划线，减号)"},
		             {inputValue: function() {
		            	 return $("#add-i-phone").val()
		             }, regValue:/^[1][3,4,5,7,8,9][0-9]{9}$/, noticeText:"无效的手机号码"},	
		             {inputValue: function() {
		            	 return $("#add-i-qq").val()
		             }, regValue:/^[1-9][0-9]{4,10}$/, noticeText:"无效的QQ号码"},  
		             ],
		callback: function() {
			if (!$("#add-i-pass").val() || !$("#add-i-passRepeat").val()) {
				return "密码不得为空!"
			}					
			if ($("#add-i-pass").val() != $("#add-i-passRepeat").val()) {
				return "两次密码不一致!"
			}
			if (IS_USER_EXITS) {
				return "该用户已存在!"
			}
			return checkPassWordValid($("#add-i-passRepeat").val())
		},
	}
	checkFormMethod(obj, function() {
		var newRequest = {
			url: "/kajhsgweasdqtwehghasfdnsak6868/createdUserAccountInfo.do",	
			type: "post",
			data: {},
			success: function(result) {
				$('#addNewAccountModal').modal("hide");
				var data = JSON.parse(result);
				if(data.data==1){
					showNoticeModal("创建成功！");
				}else{
					showNoticeModal("创建失败！");
				}
				$("#table-i-userList").dataTable().fnDestroy();
				dataTable01();
			},
			error: function(status) {
				showNoticeModal("网络繁忙！")
			}
		}
		$("[data-add]").each(function(index, element) {
			newRequest.data[element.dataset.add] = element.value
		})
		ajax(newRequest)
	})	
	
	var OBJECT_DATA={};
		layui.use('laydate', function() {
			var laydate = layui.laydate;
			laydate.render({
				elem : '#test1' //指定元素
			});
			laydate.render({
				elem : '#test2' //指定元素
			});
		});
		    var names="";
		    function dataTable01(){
				$("#table-i-userList").DataTable({
					 "bProcessing" : false, // 是否显示取数据时的那个等待提示
					"bServerSide" : true,//这个用来指明是通过服务端来取数据
					 "bPaginate" : true, //是否显示分页 
					"sAjaxSource" : "/kajhsgweasdqtwehghasfdnsak6868/findAllUsers.do",//这个是请求的地址
					"fnServerData" : retrieveData, // 获取数据的处理函数
				/* 	"destroy":true, */
				      // "bPaginate": true,
				       "bLengthChange": true,      
				      "bSort": false,
				      // "bInfo": true,
				      "bAutoWidth": false,
//				         "bServerSide":true,
				      'aLengthMenu':[5,10, 20], 
				       "searching": false,  
				       /* "pagingType": "simple_numbers", */
				        "dom": "t<'tableinfo'i<'tableSearch'p>l>",   
				       
				       "language": {//语言设置  
				            "lengthMenu": "每页显示 _MENU_ 条记录",     
				            "zeroRecords": "没有检索到数据",     
				            "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",  
				            "info": "没有数据",     
				            "oPaginate": {     
				                "sFirst": "首页",     
				                "sPrevious": "前一页",     
				                "sNext": "后一页",     
				                "sLast": "尾页"    
				          	},
				            "search":"",
				            "searchPlaceholder": "请输入关键字",
				            "infoFiltered":   "(从  _MAX_ 记录中搜索出结果)",
				            "infoEmpty":      "没有找到匹配的信息",
				         }, 
				         "columnDefs": [{"defaultContent": "",
                             "targets": "_all"}],
				        "aoColumns": [
				        	 {"data": "id", "className": "userId-td hidden-td"},
							 {"data": "name", "className": "yonghuming-td"},
							 {"data": "balance", "className": "sex-td"},
		                     {"data": "registerTime", "className": "phone-td"},
		                     {"data": "lastTime", "className": "njob-td"},
		                     {"data": "telephone", "className": "phone-td"},
		                     {"data": "registerIp", "className": "njob-td"},
		                     {"data": "lastIp", "className": "njob-td"},
		                     {"data": "vip", "className": "njob-td"},
		                     {"data": "state"},
		                     {"data":  "caozuo"},  
		                 ], 
				})
				
				function retrieveData(sSource, aoData, fnCallback) {
				$.ajax({
					url : sSource,//这个就是请求地址对应sAjaxSource
					data : {
						"name":names,//会员账号
						"ip":$("#signinIp").val(),//登录
						"bankCard":$("#bankCardNumber").val(),//银行卡
						"cname":$("#bankAccountName").val(),//绑定银行卡的姓名
						"pageCount":aoData[0].value,
						"startIndex":aoData[3].value,
						"lineCount":aoData[4].value,
					},//这个是把datatable的一些基本数据传给后台,比如起始位置,每页显示的行数
					type : 'post',
					dataType : 'json',
					async : false,
					success : function(result) { 
						 var name=""
						 var newData = result.aaData
		        		 for (var i = 0; i < newData.length; i++) {
		        			var item = newData[i]
		        			item['caozuo']=""
		        			 var xiangqing="<button class='btn btn-success btn-edit-UserInfo'>用户详情</button>"
				        			if(item.state==0 ||item.state==1){
				        				item.caozuo=xiangqing+"   <button class='btn btn-danger btn-edit-UserPassWord'>修改密码</button>   <button class='btn btn-info btn-editUserBankInfo'>修改银行卡</button>"
				        			}else if(item.state==3){
				        				item.caozuo=xiangqing+"   <button class='btn btn-danger btn-edit-UserPassWord'>修改密码</button>"
				        			}
		        			if(item.state==0){
		        				item.state="<button class='btn-control-startOrBan btn btn-primary'>禁用</button>"
		        			}else if(item.state==1){
		        				item.state="<button class='btn-control-startOrBan btn btn-success'>启用</button>"
		        			}else if(item.state==3){
		        				item.state="内部账号"
		        			}
 		        		} 
						 result.aaData = newData; 
						fnCallback(result);//把返回的数据传给这个方法就可以了,datatable会自动绑定数据的
					},
					error : function(msg) {
					}
				});
			}
		 }	
		     dataTable01()
		    insertSearchBtn()
			var bindResetBtnEvent = function() {
				var btn = document.querySelector("#id-resetTableBtn")
				btn.addEventListener("click", function(event) {
					names=document.querySelector("#guanjianzi").value = "" 
					$("#table-i-userList").dataTable().fnDestroy();
					 dataTable01(); 
				})
			}	
			
			var bindSearchBtnEvent = function() {
				var btn = document.querySelector("#id-searchTableBtn")
				btn.addEventListener("click", function(event) {
					$("#table-i-userList").dataTable().fnDestroy();
					 names = document.querySelector("#guanjianzi").value;
					  dataTable01();  
				})
			}
			bindSearchBtnEvent()
			bindResetBtnEvent()
			$("#table-i-userList").on("click", function(event) {
				var $Event = $(event.target)
				var $Parent = $Event.closest("tr")
				if ($Event.hasClass("btn-control-startOrBan")) {
					     var urlPath = "/kajhsgweasdqtwehghasfdnsak6868/updateUserAccountState.do"
					     var stateValue
						 if($Event.text()=="禁用"){
							stateValue=1;
						}
						else if($Event.text()=="启用"){
							stateValue=0;
						} 
					var newRequest = {
						url: urlPath,
						type: "post",
						data: {
							id: $Parent.find(".userId-td").text(),
							name: $Parent.find(".yonghuming-td").text(),
							state: stateValue,
						},
						success: function(data) {
							var newData = data.data
							if (newData== "修改失败") {
								showNoticeModal("修改状态失败，请稍后重试")
								return
							}
							if (stateValue == "1") {
								$Event.removeClass("btn-primary").addClass("btn-success").text("启用")
							} else {
								$Event.removeClass("btn-success").addClass("btn-primary").text("禁用")
							}
						},
						error: function(status) {
							console.log("status", status)
						}
					}
					ajax(newRequest)					
				}
				else if ($Event.hasClass("btn-edit-UserInfo")) {
					var urlPath = "/kajhsgweasdqtwehghasfdnsak6868/findUserInfo.do"
						var newRequest = {
							url: urlPath,
							type: "post",
							data: {
								name: $Parent.find(".yonghuming-td").text(),
							},
							success: function(data) {
								var newData = JSON.parse(data)
								for (k in newData.data) {
									var $Item = $("#editAndBianJiModal .modal-body").find("#input-i-" + k)
									if ($Item.length > 0) {
										$Item.val(newData.data[k])
									}
								}
								$("#input-i-dailimingchen").val(newData.message)
								$("#editAndBianJiModal").modal("show")
							},
							error: function(status) {
								console.log("status", status)
							}
						}
						ajax(newRequest)						
				}
				else if ($Event.hasClass("btn-edit-UserPassWord")) {
					$("#editPassWord")[0].dataset.userid = $Parent.find(".userId-td").text()
					$("#editPassWord")[0].dataset.name = $Parent.find(".yonghuming-td").text(),
					$("#editPassWord").modal("show")
				}
			})
			//
			$("#table-i-userList").on("click", ".btn-editUserBankInfo", function(event) {
				var $parentTr = $(event.currentTarget).closest("tr")
				ajax({
					url: "/kajhsgweasdqtwehghasfdnsak6868/findByUserIdBankInfo.do",
					type: "post",
					data: {
						id: $parentTr.find(".userId-td").text(),
					},
					success: function(data) {
						var newData = JSON.parse(data)
						if (newData.data === 0) {
							showNoticeModal("该会员还未绑定银行卡账号，无法修改！")
							return
						}
						  $("#editBankCard .input-bank-auto").each(function(index, element) {
							  var name = element.name
							  $(element).val(newData.data[name])
						  })
						  $("#editBankCard [name='repeatfupass']").val($("#editBankCard [name='zhifupass']").val())
						  $("#editBankCard").attr("data-editid", $parentTr.find(".userId-td").text())
						  $("#editBankCard").modal("show")
					},
					error: function(status) {
						console.log("status", status)
					}					
				})
			})
			$("#btn-i-saveNewPassWord").on("click", function(event) {
				var result = checkPassWordValid($("#input-i-newPassWordValue").val())
				if (result != "ok") {
					showNoticeModal(result)
					return
				}
				var urlPath = "/kajhsgweasdqtwehghasfdnsak6868/updateUserPassword.do"
					var newRequest = {
						url: urlPath,
						type: "post",
						data: {
							id: $("#editPassWord")[0].dataset.userid,
							name: $("#editPassWord")[0].dataset.name,
							pass: $("#input-i-newPassWordValue").val(),
						},
						success: function(data) {
							var newData = JSON.parse(data);
							$("#editPassWord").modal("hide")
							showNoticeModal(newData.data);
						},
						error: function(status) {
							console.log("status", status)
						}
					}
					ajax(newRequest)		
			})
		
		var NUMBERS = "1234567890"
		var checkIsNumber = function(s1) {
			if (!s1) {
				return false
			}
			for (var i = 0; i < s1.length; i++) {
				var letter = s1[i]
				if (!NUMBERS.includes(letter)) {
					return false
				}
			}
			return true			
		}			
			var obj = {
				btnName: "#btn-i-saveNewBankBtn",
				divName: "#editBankCard",
	            callback: function() {
	    			var accountValue = $("#editBankCard [name='bankNum']").val()
	    			if (!checkIsNumber(accountValue)) {
	    				return "银行账号输入有误"
	    			}
	    			if (accountValue.length < 16) {
	    				return "银行账号格式有误"
	    			}
	    			var passwordValue = $("#editBankCard [name='zhifupass']").val()
	    			if (!checkPassWord(passwordValue)) {
	    				return "密码必须是6~16位, 可包含字母以及数字"
	    			}
	    			var repeatPassWordValue = $("#editBankCard [name='repeatfupass']").val()
	    			if (repeatPassWordValue != passwordValue) {
	    				return "两次密码输入不一致，请重新填写"
	    			}	
	    			return "ok"
	            }
			}
			checkFormMethod(obj, function() {
				var newData = {}
				$("#editBankCard .input-bank-auto").each(function(index, element) {
					newData[element.name] = element.value
				})
				var newRequest = {
					type: "post",
					url: "/kajhsgweasdqtwehghasfdnsak6868/updateUserBankInfo.do"
					,
					data: newData,
					success: function(result) {
						var data = JSON.parse(result)
						if(data.data==3){
							showNoticeModal("操作成功！")
						}else{
							showNoticeModal("操作失败！")
						}
						$('#editBankCard').modal("hide")
					},
					error: function(status) {
					}
				}
				ajax(newRequest)
			})
			$("#id-searchTableBtn-zhuanyi").on("click",function(){
				$("#addNewAccountModal-zhuanyi").modal("show");
			})
			$("#btn-i-addNewAccountBtn-zhuanyi").on("click",function(){
				$.ajax({
					url : "/kajhsgweasdqtwehghasfdnsak6868/transferSubordinate.do",
					data : {
						name:$("#add-i-name-Superior").val(),
						cname:$("#add-i-subordinate").val(),
						odds:$("#add-i-odds").val(),
					},
					type : 'post',
					success : function(data) {
						$('#addNewAccountModal-zhuanyi').modal("hide")
						if(data.data == 1){
							showNoticeModal("转移成功");
						}else if(data.data == 0){
							showNoticeModal("转移失败");
						}else if(data.data == -1){
							showNoticeModal("赔率不能为空");
						}else if(data.data == -2){
							showNoticeModal("赔率不能大于代理可调动的赔率");
						}else if(data.data == -3){
							showNoticeModal("设置的赔率格式不对");
						}else if(data.data = -4){
							showNoticeModal("代理或用户不存在");
						}
					},
				});
			})
	</script>
	</body>
</html>


